export namespace WeightUtil {

/**
 *  将重量转为number
 * @param weight
 * @returns
 */
  function getWeightNumber(weight: string): number {
    return parseFloat(weight);
  }
  /**
   * 将重量转为string
   * @param weight
   * @returns
   */
  function getWeightString(weight: number): string {
    return `${weight}g`;
  }

  /**
   * 获取当前字符串的单位
   * @param weight
   * @returns
   */
  function getUnit(weight: string): UnitType {
    if (weight.charAt(-1) === 'g') {
      return UnitType.gram;
    }
    return UnitType.individual;
  }


}

export enum UnitType {

  /**
   * 单位异常
   */
  UnitERROR = -1,
  /**
   * 克
   */
  gram = 1,
  /**
   * 个
   */
  individual = 2,
}